﻿using AnesSystem.Models;
using AnesSystem.Util;
using AnesSystem.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AnesSystem.Controls
{
    /// <summary>
    /// DrugListItemCtrl.xaml 的交互逻辑
    /// </summary>
    public partial class DrugListItemCtrl : UserControl
    {

        public DrugListItemCtrl()
        {
            InitializeComponent();            
        }


        public DateTime SelectDateTime
        {
            get { return (DateTime)GetValue(SelectDateTimeProperty); }
            set { SetValue(SelectDateTimeProperty, value); }
        }

        // Using a DependencyProperty as the backing store for SelectDateTime.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty SelectDateTimeProperty =
            DependencyProperty.Register("SelectDateTime", typeof(DateTime), typeof(DrugListItemCtrl), new PropertyMetadata(DateTime.Now));


        public List<DrugStatisticModel> ItemsSource
        {
            get { return (List<DrugStatisticModel>)GetValue(ItemsSourceProperty); }
            set { SetValue(ItemsSourceProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ItemsSource.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ItemsSourceProperty =
            DependencyProperty.Register("ItemsSource", typeof(List<DrugStatisticModel>), typeof(DrugListItemCtrl), new PropertyMetadata());

        private void rq_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            CusDatePickerWin cusDatePicker = new CusDatePickerWin();
            cusDatePicker.SelectedDateTime = DateTime.Now;
            cusDatePicker.ShowDialog();
            if (cusDatePicker.Result)
            {
                DrugListCtrlViewModel.Instance.SelectDateTime = cusDatePicker.SelectedDateTime;
            }
        }
    }
}
